package com.chixing.day07_abstract.prototype;
/*
* 浅克隆:类具有一些基础属性(基本数据类型+String类型====值传递)
*
* 他的克隆对象:(1)new当前类对象
*           (2)克隆对象的属性与原始对象属性一致
*
*深克隆: 类具有一些基础属性，还有关联对象
* 他的克隆对象: (1)new当前对象
*             (2)克隆对象的属性与原始对象属性一致，原始对象的关联对象也要克隆一份
*   jobClone.company = (Company)this.company.clone();
 * */
public class Product {
    private int ptoId;
    private String proName;
    private float proPrice;


    public Product(){

    }

    public Product(int ptoId, String proName, float proPrice) {
        this.ptoId = ptoId;
        this.proName = proName;
        this.proPrice = proPrice;
    }

    public int getPtoId() {
        return ptoId;
    }

    public void setPtoId(int ptoId) {
        this.ptoId = ptoId;
    }

    public String getProName() {
        return proName;
    }

    public void setProName(String proName) {
        this.proName = proName;
    }

    public float getProPrice() {
        return proPrice;
    }

    public void setProPrice(float proPrice) {
        this.proPrice = proPrice;
    }


    /*
    * 浅克隆
    * */
    @Override
    protected Object clone() throws CloneNotSupportedException {
        Product proClone = new Product();
        proClone.ptoId = this.ptoId;
        proClone.proName = this.proName;
        proClone.proPrice = this.proPrice;
        return proClone;
    }

    @Override
    public String toString() {
        return "Product{" +
                "ptoId=" + ptoId +
                ", proName='" + proName + '\'' +
                ", proPrice='" + proPrice + '\'' +
                '}';
    }
}
